import PageTemplate from '@/components/common/PageTemplate'
import {getAlreadyReadList} from '@/api/api.js'
export default {
    components:{
      PageTemplate
    },
    data() {
        return {
            brand:[
                {name:'lang.workbench'},
                {name:'lang.already_read_task'}
            ],
            hasIcon:false,
            advSearch:'adt.advance_search',
            procPicUrl:process.env.PROCPIC_ROOT,
            keysword:'',//关键字
            taskDes:'',
            procName:'',
            launcher:'',
            pageSize:10,
            pageIndex:1,
            total:0,
            searchType:0,
            searchParam:{},
            tables:[
                
            ]
        }
    },
    methods: {
        advanceSearch : function(){
            if(this.advSearch == "adt.advance_search"){
                this.advSearch = "adt.return";
            }else{
            this.advSearch = "adt.advance_search";
            }
        },
        //重置操作
        reset:function(){
            this.taskDes = "";
            this.procName = "";
        },
        showTableList(params){
            let _this = this;
            _this.tables = [];
            getAlreadyReadList(params).then((result) => {
                if(result.status == "200" && result.data.code=="0"){
                    let data = result.data.data.data;
                    //表格数据  数组            
                    _this.tables = data.resultData;
                    //分页数据
                    _this.pageSize = data.page.pageSize;
                    _this.pageIndex = data.page.startPage;
                    _this.total = data.page.totalCount;
                }else{
                    _this.$alert(result.data.msg,_this.$t('cm.tips'));
                }
            }).catch((err) => {
                _this.$alert(err,_this.$t('cm.tips'));
            });
        },
        initTableList:function(){
            //初始化列表 填充tables
            let params = {
                searchType:0,
                pageSize:this.pageSize,
                pageIndex:1,
                t:Math.random(),
            }
            this.showTableList(params);
        },
        //其他的方法  统一设置好  param  再调用 showTableList方法与后台交互
        commonSearch:function(){
            let params = {
                pageIndex:1,
                pageSize:this.pageSize,
                type:1,
                searchParams:{
                    "Folio":this.keysword
                },
                searchType:this.searchType
            }
            this.searchType=1;
            this.searchParams = {
                "Folio":this.keysword
            }
            this.showTableList(params);
        },
        advSearchs:function(){
        
            this.searchType = 2;
            this.searchParams = {
                "Folio":this.taskDes,
                "ProcessName":this.procName,
            }
            let params = {
                pageIndex:1,
                pageSize:this.pageSize,
                type:1,
                searchParams:{
                    "Folio":this.taskDes,
                    "ProcessName":this.procName,
                    "StartUserCN":this.launcher
                },
                searchType:this.searchType
            }
            this.showTableList(params);
        },
        nextPage:function(nowPage){
            let params = {
                pageSize:this.pageSize= this.pageSize+1,
                pageIndex:this.pageIndex,
                t:Math.random(),
                searchType:this.searchType,
            }
                params = Object.assign(params,this.searchParam);
            this.showTableList(params);
        },
        lastPage:function(nowPage){
            let params= {
                pageSize:this.pageSize = this.pageSize-1,
                pageIndex:this.pageIndex,
                t:Math.random(),
                searchType:this.searchType,
            }
                params = Object.assign(params,this.searchParam);
            this.showTableList(params);
        },
        selectPage:function(nowPage){
            let params= {
            pageSize:this.pageSize,
            pageIndex:this.pageIndex = nowPage,
            t:Math.random(),
            searchType:this.searchType,
            }
            params = Object.assign(params,this.searchParam);
            this.showTableList(params);
        },
        selectPageSize:function(pageSize){
            let params= {
            pageSize:this.pageSize = pageSize,
            pageIndex:this.pageIndex,
            t:Math.random(),
            searchType:this.searchType,
            }
            params = Object.assign(params,this.searchParam);
            this.showTableList(params);
        },
        //展示流程图
        showProcPic:function(row){
            window.open(this.procPicUrl+row.procInstID);
        },
    },
    mounted() {
        this.initTableList();
    },
}